/**
 * 
 */
package com.witframework.meta;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.javalid.annotations.validation.MaxLength;
import org.javalid.annotations.validation.NotEmpty;
import org.javalid.annotations.validation.NotNull;
import org.springmodules.validation.bean.conf.loader.annotation.handler.Length;

import com.witframework.core.annotations.Wit;

/**
 * 表的元数据描述
 * 
 * @author wuxinyang Jun 5, 2009 3:38:04 PM
 */

@Entity(name="MetaTable")
@Table(name = "Meta_Table")
@Wit(cnname = "表元数据")
public class MetaTable extends BaseMetaObject {
	@Column(length = 127)
	@Wit(cnname = "表名", description = "表名")
	@MaxLength(length = 127)
	@NotEmpty
	private String tableName;

	@Column(length = 1)
	@NotNull
	@Length(max = 1)
	@Wit(cnname = "视图?", description = "是否视图？")
	private String isView = "N";

	@Column(length = 1)
	@NotNull
	@Length(max = 1)
	@Wit(cnname = "可删除?", description = "是否可以删除？")
	private String isDeletable = "N";

	@Column(length = 127)
	@Wit(description = "显示列名称，在其他表引用该表时，将在其外键列上显示该列的值")
	private String viewColumn;

	@OneToMany(mappedBy = "metaTable")
	@LazyCollection(value = LazyCollectionOption.FALSE)
	private List<MetaTableColumn> columns = new ArrayList<MetaTableColumn>();

	@OneToMany(mappedBy = "metaTable")
	@LazyCollection(value = LazyCollectionOption.FALSE)
	private List<MetaTableReferentialIntegrity> refs = new ArrayList<MetaTableReferentialIntegrity>();

	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public String getIsView() {
		return isView;
	}

	public void setIsView(String isView) {
		this.isView = isView;
	}

	public String getIsDeletable() {
		return isDeletable;
	}

	public void setIsDeletable(String isDeletable) {
		this.isDeletable = isDeletable;
	}

	public List<MetaTableColumn> getColumns() {
		return columns;
	}

	public void setColumns(List<MetaTableColumn> columns) {
		this.columns = columns;
	}

	public void setViewColumn(String viewColumn) {
		this.viewColumn = viewColumn;
	}

	public void setRefs(List<MetaTableReferentialIntegrity> refs) {
		this.refs = refs;
	}

	public String getViewColumn() {
		return viewColumn;
	}

	public List<MetaTableReferentialIntegrity> getRefs() {
		return refs;
	}

}
